package com.ocom.payconfig.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.payconfig.EntityFoodstuffInfo;
import com.ocom.common.response.payconfig.OrderSummaryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoFoodstuffInfo extends BaseMapper<EntityFoodstuffInfo> {




    @Select({"<script>",
            "select     F.foodstuff_id as foodstuffId , F.foodstuff_name as foodstuffName , F.sort , \n" +
                    "C.parent_id as classParent , C.sort as classSort \n" +
                    "from     foodstuff_info as F \n" +
                    "left join    foodstuff_class C     on    C.com_id = @comId     and     C.food_class_id = F.food_class_id" +
                    " where     F.com_id = #{comId}  " +
                    " <when test=\"foodIds != null and foodIds.size() &gt; 0 \" > " +
                    " and     F.foodstuff_id in  " +
                    " <foreach collection='foodIds' item='id' open='(' separator=',' close=')'> " +
                    " #{id} " +
                    " </foreach> " +
                    "</when>" +
                    "order by  classParent , classSort , sort" +
                    "</script>"})
    List<OrderSummaryVo.FoodstuffList> getFoodstuffList(Long comId, List<Integer> foodIds);
}
